package com.push.web.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.push.common.annotation.Log;
import com.push.common.core.controller.BaseController;
import com.push.common.core.domain.AjaxResult;
import com.push.common.enums.BusinessType;
import com.push.web.domain.BizRss;
import com.push.web.service.IBizRssService;
import com.push.common.utils.poi.ExcelUtil;
import com.push.common.core.page.TableDataInfo;

/**
 * RSS订阅Controller
 *
 * @author yanxi
 * @date 2022-11-22
 */
@RestController
@RequestMapping("/information/rss")
public class BizRssController extends BaseController
{
    @Autowired
    private IBizRssService bizRssService;

    /**
     * 查询RSS订阅列表
     */
    @PreAuthorize("@ss.hasPermi('information:rss:list')")
    @GetMapping("/list")
    public TableDataInfo list(BizRss bizRss)
    {
        startPage();
        List<BizRss> list = bizRssService.selectBizRssList(bizRss);
        return getDataTable(list);
    }

    /**
     * 导出RSS订阅列表
     */
    @PreAuthorize("@ss.hasPermi('information:rss:export')")
    @Log(title = "RSS订阅", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(BizRss bizRss)
    {
        List<BizRss> list = bizRssService.selectBizRssList(bizRss);
        ExcelUtil<BizRss> util = new ExcelUtil<BizRss>(BizRss.class);
        return util.exportExcel(list, "RSS订阅数据");
    }

    /**
     * 获取RSS订阅详细信息
     */
    @PreAuthorize("@ss.hasPermi('information:rss:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(bizRssService.selectBizRssById(id));
    }

    /**
     * 新增RSS订阅
     */
    @PreAuthorize("@ss.hasPermi('information:rss:add')")
    @Log(title = "RSS订阅", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BizRss bizRss)
    {
        return toAjax(bizRssService.insertBizRss(bizRss));
    }

    /**
     * 修改RSS订阅
     */
    @PreAuthorize("@ss.hasPermi('information:rss:edit')")
    @Log(title = "RSS订阅", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BizRss bizRss)
    {
        return toAjax(bizRssService.updateBizRss(bizRss));
    }

    /**
     * 删除RSS订阅
     */
    @PreAuthorize("@ss.hasPermi('information:rss:remove')")
    @Log(title = "RSS订阅", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(bizRssService.deleteBizRssByIds(ids));
    }
}
